// This file was created by Filewrap 1.1
// Little endian mode
// DO NOT EDIT

#include "../PVRTMemoryFileSystem.h"

// using 32 bit to guarantee alignment.
#ifndef A32BIT
 #define A32BIT static const unsigned int
#endif

// ******** Start: FragShader.fsh ********

// File data
static const char _FragShader_fsh[] = 
	"uniform sampler2D\t\tNormalTex;\r\n"
	"uniform sampler2D\t\tReflectionTex;\r\n"
	"#ifdef ENABLE_REFRACTION\r\n"
	"\tuniform sampler2D\t\tRefractionTex;\r\n"
	"#endif\r\n"
	"uniform samplerCube NormalisationCubeMap;\r\n"
	"\r\n"
	"uniform mediump mat4\tModelViewMatrix;\r\n"
	"uniform lowp vec4\t\tWaterColour;\r\n"
	"#ifdef ENABLE_DISTORTION\r\n"
	"\tuniform mediump float\tWaveDistortion;\r\n"
	"#endif\r\n"
	"uniform mediump vec2 \tRcpWindowSize;\r\n"
	"\r\n"
	"varying mediump vec2 \tBumpCoord0;\r\n"
	"varying mediump vec2 \tBumpCoord1;\r\n"
	"varying mediump vec3\tWaterToEye;\r\n"
	"varying mediump float\tWaterToEyeLength;\r\n"
	"\r\n"
	"void main()\r\n"
	"{\t\r\n"
	"\t// Calculate the tex coords of the fragment (using it's position on the screen)\r\n"
	"\tlowp vec3 vAccumulatedNormal = vec3(0.0,1.0,0.0);\r\n"
	"\tmediump vec2 vTexCoord = gl_FragCoord.xy * RcpWindowSize;\r\n"
	"\t\r\n"
	"\t#ifdef ENABLE_DISTORTION\r\n"
	"\t\t// When distortion is enabled, use the normal map to calculate perturbation\r\n"
	"\t\tvAccumulatedNormal = texture2D(NormalTex, BumpCoord0).rgb;\r\n"
	"\t\tvAccumulatedNormal += texture2D(NormalTex, BumpCoord1).rgb;\r\n"
	"\t\tvAccumulatedNormal -= 1.0; // Same as * 2.0 - 2.0\r\n"
	"\t\r\n"
	"\t\tlowp vec2 vTmp = vAccumulatedNormal.xz;\r\n"
	"\t\t/* \t\r\n"
	"\t\t\tDivide by WaterToEyeLength to scale down the distortion\r\n"
	"\t\t \tof fragments based on their distance from the camera \r\n"
	"\t\t*/\r\n"
	"\t\tvTexCoord.xy -= vTmp * (WaveDistortion / length(WaterToEye));\r\n"
	"\t#endif\r\n"
	"\r\n"
	"#ifdef ENABLE_REFRACTION\r\n"
	"\tlowp vec4 vReflectionColour = texture2D(ReflectionTex, vTexCoord);\r\n"
	"\tlowp vec4 vRefractionColour = texture2D(RefractionTex, vTexCoord);\r\n"
	"\t\r\n"
	"\t#ifdef ENABLE_FRESNEL\r\n"
	"\t\t// Calculate the Fresnel term to determine amount of reflection for each fragment\r\n"
	"\t\t\r\n"
	"\t\t// Use normalisation cube map instead of normalize() - See section 3.3.1 of white paper for more info\r\n"
	"\t\tlowp vec3 vWaterToEyeCube = textureCube(NormalisationCubeMap,WaterToEye).rgb * 2.0 - 1.0;\r\n"
	"\r\n"
	"\t\tmediump float fEyeToNormalAngle = clamp(dot(vWaterToEyeCube, vAccumulatedNormal),0.0,1.0);\r\n"
	"\t\t\r\n"
	"\t\tmediump float fAirWaterFresnel = 1.0 - fEyeToNormalAngle;\r\n"
	"\t\tfAirWaterFresnel = pow(fAirWaterFresnel, 5.0);\r\n"
	"\t\tfAirWaterFresnel = (0.98 * fAirWaterFresnel) + 0.02;\t// R(0)-1 = ~0.98 , R(0)= ~0.02\r\n"
	"\t\tlowp float fTemp = fAirWaterFresnel;\r\n"
	"\t\t\r\n"
	"\t\t// Blend reflection and refraction\r\n"
	"\t\tgl_FragColor = mix(vRefractionColour, vReflectionColour, fTemp);\r\n"
	"\t#else\r\n"
	"\t\tgl_FragColor = mix(vRefractionColour, vReflectionColour, 0.4);\t// Constant mix\r\n"
	"\t#endif\r\n"
	"#else\r\n"
	"\tgl_FragColor = texture2D(ReflectionTex, vTexCoord);\t\t\t\t\t// Reflection only\r\n"
	"#endif\r\n"
	"}\r\n";

// Register FragShader.fsh in memory file system at application startup time
static CPVRTMemoryFileSystem RegisterFile_FragShader_fsh("FragShader.fsh", _FragShader_fsh, 2388);

// ******** End: FragShader.fsh ********

// This file was created by Filewrap 1.1
// Little endian mode
// DO NOT EDIT

#include "../PVRTMemoryFileSystem.h"

// using 32 bit to guarantee alignment.
#ifndef A32BIT
 #define A32BIT static const unsigned int
#endif

// ******** Start: FragShader.fsc ********

// File data
A32BIT _FragShader_fsc[] = {
0x10fab438,0xae9474a9,0x30050100,0x2501,0xd363e337,0x2000000,0x20000000,0xc2030000,0x1000000,0x4000000,0x0,0x0,0x56,0x0,0x0,0x0,0x0,0x80010000,0x55535020,0x20,0x174,0x1,0x0,0x0,0x224,0x80,0x2,0x7d,0x0,0x8,0x0,0xffffffff,0x0,0x770009,0xffff,0x2,0x0,0x10000,0x6,0x0,0x0,0x0,0x0,0x3fffc,0x40000,0x1,0x0,0xffff0003,0xffffffff,0x30000,0x800000,0x4,0x2000e,0x20001,0x40002,0x0,0x50002,0x100000,0x80002,0x1,0x90002,0x100001,0xa0002,0x2,
0xb0002,0x100002,0xffffffff,0xffffffff,0x0,0x0,0x4,0x20003,0x60000,0x80010002,0x80018001,0x8001,0x0,0x40000,0x40004,0x40004,0x10004,0x1d7ea000,0x168b4000,0x100e7020,0x568a3002,0x10867000,0x16b03002,0x11065000,0x3003,0x1b72a022,0x44b04001,0x1006d000,0x53001,0x0,0x80010002,0x80018001,0x8001,0x0,0x100000,0xf0000,0x60a000f,0x30003,0x30003,0x0,0x0,0x40004,0x40004,0x10000,0x30002,0x10001,0x0,0xa0000000,0xe003140c,0x6,0x80010000,0x55535020,0x20,0x174,0x1,0x0,0x0,0x2a4,0x80,0x2,0x7d,0x0,0x8,0x0,
0xffffffff,0x0,0x770009,0xffff,0x20002,0x0,0x10000,0x6,0x0,0x0,0x0,0x0,0x1fffc,0x40000,0x1,0x0,0xffff0003,0xffffffff,0x30000,0x800000,0x4,0x2000e,0x20001,0x40002,0x0,0x50002,0x100000,0x80002,0x1,0x90002,0x100001,0xa0002,0x2,0xb0002,0x100002,0xffffffff,0xffffffff,0x0,0x0,0x4,0x20003,0x60000,0x80010002,0x80018001,0x8001,0x0,0x40000,0x40004,0x40004,0x10004,0x1d7ca000,0x168b4000,0x10087020,0x568a3002,0x10807000,0x16b03002,0x11005000,0x3003,0x1b702022,0x44b04001,0x1000d000,0x53001,0x0,0x80010002,
0x80018001,0x8001,0x0,0x0,0xf0000,0x60a000f,0x10001,0x10001,0x0,0x0,0x40004,0x40004,0x10000,0x30002,0x10001,0x0,0xa0000000,0xe0031408,0x6,0xc00,0x803f0000,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x3000000,0x57706352,0x6f646e69,0x7a695377,0x65,0x20303,0x100,0x2040001,0x300,0x6c666552,0x69746365,0x65546e6f,0x78,0x10318,0x100,0x1000002,0x100,0x505f6c67,0x6f50584d,0x6a644173,0x747375,0x3055700,0x1000002,0x10000,0xf000408,0x0,
};

// Register FragShader.fsc in memory file system at application startup time
static CPVRTMemoryFileSystem RegisterFile_FragShader_fsc("FragShader.fsc", _FragShader_fsc, 994);

// ******** End: FragShader.fsc ********

